const { createProxyMiddleware } = require("http-proxy-middleware");

const proxySettings = {
  // "/v1/store": {
  //   target: `http://${process.env.REACT_APP_NEXT_URL}:2021`,
  //   changeOrigin: true,
  // },
  "/api": {
    target: `https://next-dev.amcax.net`,
    changeOrigin: true,
    logLevel: "debug",
  },
  "/airfoil": {
    target: `https://next-dev.amcax.net`,
    changeOrigin: true,
    logLevel: "debug",
  },
  // "/ws": {
  //   target: `http://${process.env.REACT_APP_NEXT_URL}`,
  //   ws: true,
  //   changeOrigin: true,
  //   logLevel: "debug",
  // },
  // "/corelist": {
  //   target: `http://${process.env.REACT_APP_NEXT_URL}:2025`,
  //   changeOrigin: true,
  // },
  // "/destroy": {
  //   target: `http://${process.env.REACT_APP_NEXT_URL}:2025`,
  //   changeOrigin: true,
  // },
};

module.exports = function (app) {
  for (const route in proxySettings) {
    app.use(route, createProxyMiddleware(route, proxySettings[route]));
  }
};
